package com.byb.server.service.mapper;

import com.byb.server.domain.*;
import com.byb.server.service.dto.RateDTO;

import org.mapstruct.*;

/**
 * Mapper for the entity Rate and its DTO RateDTO.
 */
@Mapper(componentModel = "spring", uses = {ProductMapper.class, SexMapper.class, })
public interface RateMapper extends EntityMapper <RateDTO, Rate> {

    @Mapping(source = "product.id", target = "productId")

    @Mapping(source = "sex.id", target = "sexId")
    @Mapping(source = "sex.sexName", target = "sexSexName")
    RateDTO toDto(Rate rate); 

    @Mapping(source = "productId", target = "product")

    @Mapping(source = "sexId", target = "sex")
    Rate toEntity(RateDTO rateDTO); 
    default Rate fromId(Long id) {
        if (id == null) {
            return null;
        }
        Rate rate = new Rate();
        rate.setId(id);
        return rate;
    }
}
